<template>
  <div class="packageOrdersList">
    <div class="table-big">
      <div class="tableAnalysis">
        <el-table
          :data="tableDataList"
          ref="customerMgtList"
        >
          <el-table-column
            :label="item.label"
            align="center"
            v-for="(item, index) in tableColumns"
            :key="index"
            :prop="item.key"
            :min-width="item.minWidth ? item.minWidth : ``"
            :fixed="item.fixed ? item.fixed : false"
            :show-overflow-tooltip="true"
          >
            <!--用于表格自定义-->
            <template slot="header" v-if="item.showHeaderTip">
              <div>
                {{ item.label }}
                <el-tooltip effect="dark" :content="item.showHeaderTip" placement="top">
                  <span><i class="el-icon-question"></i></span>
                </el-tooltip>
              </div>
            </template>
            <template slot-scope="scope">
              <div v-if="item.key=='msg'" class="msg">{{ scope.row[item.key] }} <i class="el-icon-edit" v-hasPermi="['system:enterprise:edit']" @click="getMsg"></i></div>
              <div v-else>{{ scope.row[item.key] }}</div>
            </template>
          </el-table-column>
          <el-table-column
            fixed="right"
            label="操作"
            align="center"
            width="120">
            <template slot-scope="scope"> 
              <el-button v-hasPermi="['system:enterprise:delete']" @click="handleDel(scope.row)" type="text" size="small">删除企业</el-button>
            </template>
          </el-table-column>
        </el-table>
        <pagination
          v-show="total>0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />
      </div>
    </div>
    <addOrEditMsg v-if="showAddOrEditMsg" :visableIf.sync="showAddOrEditMsg"></addOrEditMsg>
  </div>
</template>
<script>
import {listUser} from "@/api/system/user";
import {getTime} from "@/utils";

export default {
  name: "packageOrdersList",
  components: {
    'addOrEditMsg': () => import('./addOrEditMsg.vue'),
  },
  data() {
    return {
      showAddOrEditMsg: false,
      queryParams: {},
      userList: [
        {
          value: '1',
          label: '员工1'
        }, {
          value: '2',
          label: '员工2'
        }
      ],
      tableHeight: 600,
      tableColumns: [
        {key: 'name', label: `企业全称`, visible: true, minWidth: 150, fixed: true},
        {key: 'mobile', label: `企业简称`, visible: true, minWidth: 150, fixed: false,},
        {key: 'msg', label: `备注`, visible: true, minWidth: 200,},
      ],
      tableDataList: [],
      total: 8, // 表格的总条数
    }
  },
  watch: {},
  created() {
    //this.getList();
    this.tableDataList = [];
    for (let i = 0; i < 3; i++) {
      let obj = {
        name: '2023-12-12',
        mobile: 0,
        msg: '加油',
      }
      this.tableDataList.push(obj);
    }
  },
  methods: {
    /** 查询用户列表 */
    getList() {
      this.loading = true;
      listUser(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
          this.tableDataList = response.rows;
          this.total = response.total;
          this.loading = false;
        }
      );
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    handleDel(row) {
      this.$msgBox.showMsgBox({
        title: "你确定删除该企业？",
        content: "删除企业需先删除该企业所属的所有企微号可在管理企微号页面删除企微号",
      })
          .then(async (val) => {
            this.$message({
              type: "success",
              message: "删除成功!",
            });
          })
          .catch(() => {
            this.$message({
              type: "info",
              message: "已取消删除",
            });
          });
    },
    getMsg(row) {
      this.showAddOrEditMsg=true;
    },
  },
}
</script>


<style scoped lang="scss">
.timeType {
  display: flex;
  align-items: center;
  margin-right: 10px;

  li {
    border: 1px solid #eee;
    height: 32px;
    margin: 0;
    padding: 0 15px;
    list-style: none;
    cursor: pointer;

    &.active {
      border-color: #2d8cf0;
      color: #2d8cf0;
    }
  }
}

.time-big {
  display: flex;
  align-items: center;
}

.formGroup {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  width: 100%;
}

.center-title {
  height: 30px;
  display: flex;
  align-items: center;

  span {
    content: "";
    width: 4px;
    height: 14px;
    background-color: #3070ff;
    display: block;
    margin-right: 5px;
  }
}

.tableAnalysis {
  padding-bottom: 20px;
  position: relative;

  .center-title {
    margin-bottom: 20px;
  }

  .exportData {
    position: absolute;
    right: 0px;
    top: 0px;

  }
}

.packageOrdersList {
  padding: 16px;
}

.table-big {
  background: #fff;
  padding: 10px;
}

.search {
  display: flex;

  ::v-deep.el-input__inner {
    border-right: none !important;
    border-radius: 4px 0px 0px 0px;
  }

  ::v-deep .el-button--default {
    border-radius: 0px 4px 4px 0px;
    padding: 0px 10px;
  }
}

.status {
  padding: 2px 7px;
  background-color: rgb(0, 194, 112);
  display: inline-block;
  border-radius: 4px;
  font-size: 12px;
  color: #fff;

  &.red {
    background-color: rgb(251, 88, 78);
  }
}

.number-big {
  padding: 12px;
  background: #fff;
  display: flex;
  align-items: center;
  margin-bottom: 16px;
  border-radius: 4px;

  .number {
    margin-right: 30px;
  }

}

.qrCode {
  width: 130px;
  margin: auto;
  display: flex;
  justify-content: center;
  flex-direction: column;

  .qrCode-img {
    width: 120px;
    margin-bottom: 20px;
  }

  img {
    width: 120px;
    margin-bottom: 20px;
  }
}

.title {
  font-size: 14px;
  display: flex;

  img {
    width: 26px;
    height: 26px;
  }
}

.msg {
  i {
    font-size: 16px;
    color:#3b74ff;
    cursor: pointer;
  }
}
</style>
